package cn.desk.parameter.action;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import cn.desk.commons.action.CurdAction;
import cn.desk.commons.entity.PageMode;
import cn.desk.parameter.entity.Parameter;

public class ParameterAction<T extends Parameter> extends CurdAction<T> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String add() {
		String id = getT().getId().toUpperCase();
		getT().setId(id);
		String result = super.add();
		if (getT().isPutSession() == 1) {
			setSession(getT().getId(), getT().getRealValue());
		}
		return result;
	}

	@Override
	public String update() {
		String result = super.update();
		removeSession(getT().getId());
		if (getT().isPutSession() == 1) {
			setSession(getT().getId(), getT().getRealValue());
		}
		return result;
	}

	@Override
	public String delete() {
		removeSession(getT().getId());
		return super.delete();
	}

	@Override
	public List<T> getList() {
		return super.getList();
	}

	@Override
	public Map<String, List<String>> getFieldErrors() {
		return super.getFieldErrors();
	}

	@Override
	public Collection<String> getActionErrors() {
		return super.getActionErrors();
	}

	@Override
	public T getT() {
		return super.getT();
	}

	@Override
	public PageMode<T> getPageMode() {
		return super.getPageMode();
	}

	@Override
	public String getModeName() {
		return "parameter";
	}
}
